package org.chen.spring.cloud.finchley.controller;

import io.swagger.annotations.ApiParam;
import org.chen.spring.cloud.finchley.model.User;
import org.chen.spring.cloud.finchley.service.UserFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chensj
 * @date 2020-02-07 21:01
 */
@RestController
@RequestMapping(value = "user")
public class UserController {
    @Autowired
    private UserFeignService userFeignService;

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public String addUser(@RequestBody @ApiParam(name="用户",value="传入json格式",required=true)User user){
        return userFeignService.addUser(user);
    }

    /**
     * 用户更新
     *
     * @param user 用户信息
     * @return 结果
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public String updateUser(@RequestBody @ApiParam(name="用户",value="传入json格式",required=true)User user){
        return userFeignService.updateUser(user);
    }
}
